package cc.comac.mom.config;

import javax.xml.ws.Endpoint;

import cc.comac.mom.webservice.*;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WebServiceConfig {

	@Autowired
	private Bus bus;
	@Autowired
	private QualitySapPurchaseOrderWebService qualitySapPurchaseOrderWebService;

	@Autowired
	private QualityCorrectionPlatformWebService qualityCorrectionPlatformWebService;

	@Autowired
	private QualityQarVerifyPlanWebService qualityQarVerifyPlanWebService;

	@Autowired
	private QualityQarProblemFormExternalService qualityQarProblemFormExternalService;

	@Autowired
	private QualityQarConditionalSentMaterielService qualityQarConditionalSentMaterielService;

	@Autowired
	private TestDataManageWebService testDataManageWebService;
	@Autowired
	private TestPclrDataManageWebService testPclrDataManageWebService;
	// 接受采购单数据接口
	@Bean
	public Endpoint endpoint() {
		Endpoint endpointImpl = new EndpointImpl(bus, qualitySapPurchaseOrderWebService);
		endpointImpl.publish("/purchaseOrder");
		return endpointImpl;
	}

	// 与纠正平台有关接口
	@Bean
	public Endpoint endpoint2() {
		Endpoint endpointImpl = new EndpointImpl(bus, qualityCorrectionPlatformWebService);
		endpointImpl.publish("/CorrectionPlatform");
		return endpointImpl;
	}

	// 纠正措施新增或删除验证计划
	@Bean
	public Endpoint endpoint3() {
		Endpoint endpointImpl = new EndpointImpl(bus, qualityQarVerifyPlanWebService);
		endpointImpl.publish("/QarVerifyPlan");
		return endpointImpl;
	}

	// 问题单相关接口
	@Bean
	public Endpoint endpoint4() {
		Endpoint endpointImpl = new EndpointImpl(bus, qualityQarProblemFormExternalService);
		endpointImpl.publish("/QarProblemForm");
		return endpointImpl;
	}

	// 接收有条件发料接口数据
	@Bean
	public Endpoint endpoint5() {
		Endpoint endpointImpl = new EndpointImpl(bus, qualityQarConditionalSentMaterielService);
		endpointImpl.publish("/ConditionalSentMateriel");
		return endpointImpl;
	}

	// 实验数据管理系统
	@Bean
	public Endpoint endpoint6() {
		Endpoint endpointImpl = new EndpointImpl(bus, testDataManageWebService);
		endpointImpl.publish("/TestDataManage");
		return endpointImpl;
	}

	// 实验结果回传接口
	@Bean
	public Endpoint endpoint7() {
		Endpoint endpointImpl = new EndpointImpl(bus, testPclrDataManageWebService);
		endpointImpl.publish("/TestPclrDataManage");
		return endpointImpl;
	}
}
